package com.oa.modules.approvalsec1.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.oa.common.utils.AppUtils;
import com.oa.common.utils.PageUtils;
import com.oa.common.utils.Query;
import com.oa.modules.approvalsec1.entity.Propulsion;
import com.oa.modules.approvalsec1.dao.PropulsionDao;
import com.oa.modules.approvalsec1.service.PropulsionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (Propulsion)表服务实现类
 *
 * @author makejava
 * @since 2020-11-18 11:03:35
 */
@Service("propulsionService")
public class PropulsionServiceImpl extends ServiceImpl<PropulsionDao,Propulsion> implements PropulsionService {
    @Resource
    private PropulsionDao propulsionDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Propulsion queryById(Long id) {
        return this.propulsionDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Propulsion> queryAllByLimit(int offset, int limit) {
        return this.propulsionDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param propulsion 实例对象
     * @return 实例对象
     */
    @Override
    public Propulsion insert(Propulsion propulsion) {
        this.propulsionDao.insert(propulsion);
        return propulsion;
    }

    /**
     * 修改数据
     *
     * @param propulsion 实例对象
     * @return 实例对象
     */
    @Override
    public Propulsion update(Propulsion propulsion) {
        this.propulsionDao.update(propulsion);
        return this.queryById(propulsion.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.propulsionDao.deleteById(id) > 0;
    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        return new PageUtils(this.page(new Query<Propulsion>().getPage(params), AppUtils.setQueryWrapper(new QueryWrapper<Propulsion>(), AppUtils.checkMap(params), "id", false)));
    }

    @Override
    public List<Propulsion> queryAll(Propulsion propulsion) {
        return propulsionDao.queryAll(propulsion);
    }
}
